
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.Text;

namespace Swaf.Gui
{
	public class ActiveWidget
	{
		protected IBizProcCoordinator m_bpc;
		protected WidgetOfflineState m_offlineState;
		public IWidget Widget;

        protected bool m_createdFromPage=false;
        public bool CreatedFromPage 
        { 
            get { return m_createdFromPage; } 
            set { m_createdFromPage = value; } 
        }


		public ActiveWidget(IWidget widget, IBizProcCoordinator bpc, WidgetOfflineState offlineState)
		{
			CreatedFromPage = true;
			Widget = widget;
			setup(bpc, offlineState);
			if(bpc.HostView != null)
				bpc.HostView.WidgetCreated(this);
		}

		public ActiveWidget(IBizProcCoordinator bpc, WidgetOfflineState offlineState)
		{
			setup(bpc, offlineState);
			Widget = Cmn.callCtor(offlineState.FullyQualifiedClassName, new Type[] { typeof(ActiveWidget) }, new object[] { this }) as IWidget;
			if(bpc != null && bpc.HostView != null)
				bpc.HostView.WidgetCreated(this);
		}

		protected void setup(IBizProcCoordinator bpc, WidgetOfflineState offlineState)
		{
			m_bpc = bpc;
			m_offlineState = offlineState;
		}
		public WidgetOfflineState State { get { return m_offlineState; } }
	}
}
